<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@taglib prefix="mvc" uri="http://www.springframework.org/tags/form" %>
<%@taglib prefix="fmt" uri="http://www.springframework.org/tags" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>签到</title>
    <link rel="stylesheet" href="/lib/layui/layui/css/layui.css">
    <link rel="stylesheet" href="/lib/zTreeStyle/zTreeStyle.css">
    <link rel="stylesheet" href="/lib/layui/layui/css/common.css">
    <link rel="stylesheet" href="/lib/layui/layui/css/eleTree.css">
    <script src="/lims/layui/layui.js"></script>
    <link rel="stylesheet" href="/lib/layer/skin/default/layer.css">
    <script type="text/javascript" src="/lims/layui/global.js"></script>
    <script type="text/javascript" src="/js/jquery/jquery-1.9.1.js"></script>
    <script src="/js/base/base.js" type="text/javascript" charset="utf-8"></script>
    <script src="/lims/js/common.js?v=20190726" type="text/javascript" charset="utf-8"></script>
    <script src="/js/base/base.js" type="text/javascript" charset="utf-8"></script>
    <script src="/lib/layui/layui/layui.js"></script>
    <script type="text/javascript" src="/lib/layui/layui/global.js/"></script>
    <script src="/lib/layui/layui/js/baseCode/base.js?v=2019080918:09" type="text/javascript" charset="utf-8"></script>
    <style>
        html,body{
            width:100%;
            height:100%;
        }
        #content{
            padding:10px;
            width:calc(100% - 20px);
            height:calc(100% - 20px);
        }
        .title{
            font-size: 24px;
            line-height: 45px;
        }
        img{
            width:100%;
            height: 200px;
        }
        .user{

        }
        #pingCon{
            display: none;
        }
        .bmIpt{
            display: none;
        }
        .layui-form-label{
            width: 100px;
        }
        .layui-input-block{
            width: 50%;
            margin-left: 130px;
        }
    </style>
</head>
<body>
    <div id="content">
        <%--<img src="" alt="" class="imgCon">--%>
        <p class="title"></p>
        <p ><span>讲师：</span><span class="user"></span></p>
            <div style="overflow: hidden">
                <div id="title" style="float:left;width:60px;"></div><div id="time" style="float:left;width:calc(100% - 60px)"></div>
            </div>
        <div style="text-align: center;margin-top: 10px;">
            <form class="layui-form" action="">
                <div class="layui-form-item">
                    <label class="layui-form-label">姓名：</label>
                    <div class="layui-input-block">
                        <input type="text" name="byname" required  lay-verify="required" placeholder="" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item bmIpt" id="tel"  style="display: none">
                    <label class="layui-form-label">手机号：</label>
                    <div class="layui-input-block">
                        <input type="text" name="tel" required  lay-verify="required" placeholder="" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item comment">
                    <label class="layui-form-label">打分(1-10分)：</label>
                    <div class="layui-input-block">
                        <input type="text" name="fraction" required  lay-verify="required" placeholder="" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item pingCon" id="pingCon" style="display: none">
                    <label class="layui-form-label">评估内容：</label>
                    <div class="layui-input-block">
                        <textarea name="desc" placeholder="请输入内容" class="layui-textarea"></textarea>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">课程名称：</label>
                    <div class="layui-input-block" id="scheduleName" style="padding-top: 10px; ">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">上课地点：</label>
                    <div class="layui-input-block" id="courseAddress" style="padding-top: 10px; ">
                    </div>
                </div>
                <div class="layui-form-item apply" style="display: none">
                    <label class="layui-form-label">报名开始时间：</label>
                    <div class="layui-input-block" id="enrollTime" style="padding-top: 10px; ">
                    </div>
                </div>
                <div class="layui-form-item apply" style="display: none">
                    <label class="layui-form-label">报名结束时间：</label>
                    <div class="layui-input-block" id="enrollTime1" style="padding-top: 10px; ">
                    </div>
                </div>
                <div class="layui-form-item signIn" style="display: none">
                    <label class="layui-form-label">签到开始时间：</label>
                    <div class="layui-input-block" id="siginTime" style="padding-top: 10px; ">
                    </div>
                </div>
                <div class="layui-form-item signIn" style="display: none">
                    <label class="layui-form-label">签到结束时间：</label>
                    <div class="layui-input-block" id="siginTime1" style="padding-top: 10px; ">

                    </div>
                </div>
                <div><button type="button" class="layui-btn btn">签到</button>
                </div>
            </form>
        </div>
    </div>



    <script>
        var id = $.GetRequest().courseId;
        var scheduleId = $.GetRequest().scheduleId;

        var type = $.GetRequest().type;
        var url = ''

        if(type == 0){
            $('.apply').hide();
            $('.signIn').show();
            $('.comment').hide()
            $('#brand').show();
            $('#cate').show();
            $('#tel').show();
            $('.btn').text('签到')
            document.title = '签到'
            url='/trCourseManage/signIn'
        }else if(type == 1){
            $('.apply').show();
            $('.signIn').hide();
            $('.comment').hide()
            $('.btn').text('报名')
            $('.bmIpt').show()
            document.title = '报名'
            url='/trCourseManage/signUp'

        }else if(type == 2){
            $('.signIn').hide();
            $('.apply').hide();
            $('.comment').show()
            $('.btn').text('评估');
            document.title = '评估'
            $('.pingCon').show()
            $('#tel').show();
            url='/trCourseManage/evlute'
        }
        function checkTime(start,end,thisTime){
            if(start==''){
                var startTime = 0
            }else{
                var startTime = new Date(start.replace('-','/')).getTime()||0;
            }
            if(end==''){
                var endTime = 0
            }else{
                var endTime = new Date(end.replace('-','/')).getTime()||0;
            }

            var thisTime = new Date(thisTime.replace('-','/')).getTime()||0;
            if(Number(startTime)<=Number(thisTime)&&Number(thisTime)<=Number(endTime)){
                return true;
            }else{
                return false;
            }
        }
            layui.use(['element', 'form', 'rate'], function () {
                var $ = layui.jquery
                    , element = layui.element
                    , form = layui.form
                    , rate = layui.rate; //Tab的切换功能，切换事件监听等，需要依赖element模块
                $.ajax({
                    url: '/trCourse/showDetils',
                    data: {courseId: id},
                    type: 'get',
                    dataType: 'json',
                    success: function (res) {
                        var data = res.object;
                        var data1=res.data;
                        $('.user').html(data.courseLecturer)

                    }
                });
                function undefind_nullStr(value) {
                    if (value == undefined) {
                        return ""
                    }
                    return value
                }
                $.ajax({
                    url: '/trCourseSchedule/showDetils',
                    data: {scheduleId: scheduleId},
                    type: 'get',
                    dataType: 'json',
                    success: function (res) {
                        var data = res.object;
                        $("#scheduleName").html(undefind_nullStr(data.scheduleName));
                        $("#courseAddress").html(undefind_nullStr(data.courseAddress));
                        $("#enrollTime").html(undefind_nullStr(data.enrollTime));
                        $("#enrollTime1").html(undefind_nullStr(data.enrollTime1));
                        $("#siginTime").html(undefind_nullStr(data.siginTime));
                        $("#siginTime1").html(undefind_nullStr(data.siginTime1));

                        $('.title').html(res.object.scheduleName);

                        if (type == 1) {
                            $('#title').html('报名时间:')
                            $('#time').html(data.enrollTime+'~'+data.enrollTime1)
                            $('#time').attr('time', data.enrollTime)
                        } else if (type == 0) {
                            $('#title').html('签到时间:')
                            $('#time').html(data.siginTime+'~'+data.siginTime1)
                            $('#time').attr('time', data.siginTime)
                        }
                        // $('#time').html(data.)
                        var ins1 = rate.render({
                            elem: '#ping'  //绑定元素
                            , value: data.star
                            , readonly: true
                        });
                    }
                });
                $('.btn').click(function () {
                    var data = {
                        name: $('[name="byname"]').val(),
                        courseId: id,
                        scheduleId:scheduleId,
                        phone: $('[name="tel"]').val()
                    }
                    if (type == 2) {
                        data.content = $('[name="desc"]').val()
                        data.fraction = $('[name="fraction"]').val()
                        // data.grade = $('[name="grade"]').val()
                    }
                    $.ajax({
                        url: url,
                        data: data,
                        type: 'get',
                        dataType: 'json',
                        success: function (res) {

                            $.layerMsg({content: res.msg, icon: 1})
                        }
                    });
                })
            })

    </script>
</body>
</html>